import md5 from 'js-md5'
import store from '@/store'

export function si (config) {
  // eslint-disable-next-line one-var
  let si, u = config.url, b = JSON.stringify(config.data), m = config.method, up = decodeURIComponent(config.url.split('?')[1]), ua = navigator.userAgent, s = store.state.signature.salt
  m === 'get' ? u.indexOf('salt') !== -1 ? si = md5((up).replace(/\s+/g, '')) : si = md5((up + s).replace(/\s+/g, '')) : si = md5((b + ua + s).replace(/\s+/g, ''))
  return si
}
